{layout name="public/layout" /}
{include file='yxnavbar'}


{include file='../../plugin/shopplan/template/web/shopplan_common_nav'}
{if $system['is_shop_plan']==1}

<form id="form3"  action="" enctype ="multipart/form-data" method="post">
<div class="panel panel-default" role="tabpanel" style="">
    <div class="panel-heading">编辑规划</div>
       <div class="panel-body" >	
			<div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><b>规划名称</b></label>
                <div class="col-sm-9 col-xs-12" >
					规划名称<label class="radio-inline"><input type="text" name="tplname" maxlength="18" value="{$item['tplname']}"></label>
					<span class="help-block">最大长度18个字</span>
				</div>
			</div>
			
           <!--<div class="form-group">
               <label class="col-xs-12 col-sm-3 col-md-2 control-label"><b>月龄限制</b></label>
               <div class="col-sm-9 col-xs-12" >
                   月龄限制<label class="radio-inline">
                   <a href="{php echo createWebUrlPlugin('shopplan.agelimit',array('s_workid'=>$item['id'],'agelimit'=>$item['agelimit'],'themeid'=>$themeid,'storeid'=>$storeid,'plantimeid'=>$plantimeid,'shopname'=>$shopname,'shopid'=>$shopid));}" onclick="if(!confirm('您要改变规划{$s_work['tplname']}的年龄限制状态？')) return false;">
                       {if $item['agelimit']==1}
                       <div>
                           <div>
                               <span style="background-color: #428bca; padding: 2px 8px;border:1px solid #CCCCCC;border-radius:5px;color: white;">ON</span>
                               <span style="background-color: #ffffff; padding: 2px 7px;border:1px solid #CCCCCC;border-left: 0px;border-radius:3px; margin-left:-6px;color: #ffffff;">OFF</span>
                           </div>
                       </div>
                       {else}
                       <div>
                           <div>
                               <span style="background-color: #ffffff; padding: 3px 10px;border:1px solid #CCCCCC;border-radius:5px;color: #ffffff;">ON</span>
                               <span style="background-color: #eeeeee; padding: 3px 8px;border:1px solid #CCCCCC;border-left: 0px;border-radius:3px;margin-left:-12px;color: #000000;">OFF</span>
                           </div>
                       </div>

                       {/if}
                   </a>

               </label>
                   <span class="help-block">是否启用“月龄限制”</span>
               </div>
           </div>-->

           <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><b>规划规则</b></label>
				<div class="col-sm-9 col-xs-12">
                    <table class='table'>
                        <thead>
                        <tr>
							<th>每工作日可预约时间段</th>
                            <th>本时间段可预约客户数量</th>
                            {if $store_item['agelimit']==1}
                                <th>本时间段适用的宝宝月龄</th>
                            {/if}
							<th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="yx_special_plan_items">
						{if empty($s_work_rules)}
                        <tr >
                            <td><input type="time" name="s_work[0][worktimes]" value="08:45"/></td>
							<td><input name="s_work[0][nums]" type="number" min="0" value="1"/></td>
                            {if $store_item['agelimit']==1}
                                <td>开始月龄<input type="number" name="s_work[0][ages_start]" value="0" min="0">&nbsp;&nbsp;&nbsp;&nbsp;最大月龄<input type="number" name="s_work[0][ages_end]" value="1200" min="0"></td>
                            {/if}
                            <td><input  name="s_work[0][id]" type="hidden" value="" /><a style="background-color: #ca4242; padding: 3px 10px;border-radius:5px; text-align:center;color: white;" href='javascript:;' onclick='removePlanItem(this)'>删除</a></td>
                        </tr>
						{else}
						{loop $s_work_rules $key $w_rule}
                        <tr >
                            <td><input name="s_work[{$key}][worktimes]" type="time"  value="{$w_rule['worktimes']}"/></td>
							<td><input name="s_work[{$key}][nums]" type="number" min="0"  value="{$w_rule['nums']}"/></td>
                            {if $store_item['agelimit']==1}
                                <td>开始月龄<input type="number" name="s_work[{$key}][ages_start]" value="{$w_rule['ages_start']}" min="0">&nbsp;&nbsp;&nbsp;&nbsp;最大月龄<input type="number" name="s_work[{$key}][ages_end]" value="{$w_rule['ages_end']}" min="0"></td>
                            {/if}
                            <td><input  name="s_work[{$key}][id]" type="hidden" value="" /><a style="background-color: #ca4242; padding: 3px 10px;border-radius:5px; text-align:center;color: white;" href='javascript:;' onclick='removePlanItem(this)'>删除</a></td>
                        </tr>
                        {/loop}
						{/if}
                        </tbody>
                    </table>
                    <a href="javascript:;" onclick="addspecialPlan();" style="background-color:#428bca;padding: 5px 10px; color: white;border-radius:5px;"><i class="glyphicon glyphicon-plus" title="addPlan"></i>添加时间段</a>
				</div>
			</div>
	
		</div>
	</div>
</div>
			<div class="form-group">
				<div class="col-sm-12">
					<input name="submit" id="btn_submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
					<input type="hidden" name="__token__" value="{$Request.token}" />
				</div>
			</div>
</form>	

{/if} 
<script>
	<!--增加工作日时间规则-->
    function addspecialPlan() {
		var k = $("#yx_special_plan_items").find('tr').size();
        var html = "<tr>";
		html += '<td><input type="time" name="s_work[' +k+ '][worktimes]" value="08:45"/></td>';
        html += '<td><input name="s_work[' +k+ '][nums]" type="number" min="0" value="1" /></td>';
        {if $store_item['agelimit']==1}
            html += '<td>开始月龄<input type="number" name="s_work[' +k+ '][ages_start]" value="0" min="0">&nbsp;&nbsp;&nbsp;&nbsp;最大月龄<input type="number" name="s_work[' +k+ '][ages_end]" value="1200" min="0"></td>';
        {/if}
        html += '<td> <input  name="s_work[' +k+ '][id]" type="hidden" value="" />&nbsp;<a style="background-color: #ca4242; padding: 3px 10px;border-radius:5px; text-align:center;color: white;" href="javascript:;" onclick="removePlanItem(this)" >删除</a></td>';
        html += "</tr>";
        $("#yx_special_plan_items").append(html);
    }
	<!--删除工作日时间规则-->
    function removePlanItem(obj) {
		
        $(obj).parent().parent().remove();
    }
</script>
